nbnl <- cell2nb(nrow = nrow(nolockdown.rast), ncol = ncol(nolockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(nolockdown.rast@data@values), lwbnl, alternative = "greater")
#Join Count Analysis for LOCKDOWN
lockdown.rast <- rasterize(lockdown.spdf, r1, field = 1)
lockdown.rast[is.na(lockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(lockdown.rast), ncol = ncol(lockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(lockdown.rast@data@values), lwbnl, alternative = "greater")
r1 <- raster(nrows=25, ncols=25, ext=jc.extent)
#Join Count Analysis for NO LOCKDOWN
nolockdown.rast <- rasterize(nolockdown.spdf, r1, field = 1)
nolockdown.rast[is.na(nolockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(nolockdown.rast), ncol = ncol(nolockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(nolockdown.rast@data@values), lwbnl, alternative = "greater")
#Join Count Analysis for LOCKDOWN
lockdown.rast <- rasterize(lockdown.spdf, r1, field = 1)
lockdown.rast[is.na(lockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(lockdown.rast), ncol = ncol(lockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(lockdown.rast@data@values), lwbnl, alternative = "greater")
r1 <- raster(nrows=50, ncols=50, ext=jc.extent)
#Join Count Analysis for NO LOCKDOWN
nolockdown.rast <- rasterize(nolockdown.spdf, r1, field = 1)
nolockdown.rast[is.na(nolockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(nolockdown.rast), ncol = ncol(nolockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(nolockdown.rast@data@values), lwbnl, alternative = "greater")
#Join Count Analysis for LOCKDOWN
lockdown.rast <- rasterize(lockdown.spdf, r1, field = 1)
lockdown.rast[is.na(lockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(lockdown.rast), ncol = ncol(lockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(lockdown.rast@data@values), lwbnl, alternative = "greater")
load(file= "nolockdown.spdf", verbose = FALSE)
nolockdown.spdf <- nolockdown
coordinates(nolockdown.spdf) <- c("longitude", "latitude")
load(file= "lockdown.spdf", verbose = FALSE)
lockdown.spdf <- lockdown
coordinates(lockdown.spdf) <- c("longitude", "latitude")
load(file= "nolockdown.spdf", verbose = FALSE)
nolockdown.spdf <- nolockdown
coordinates(nolockdown.spdf) <- c("longitude", "latitude")
load(file= "lockdown.spdf", verbose = FALSE)
lockdown.spdf <- lockdown
coordinates(lockdown.spdf) <- c("longitude", "latitude")
#Define the extent for the join count analyses for lockdown
jc.extent <- extent(39,46,30,40)
#Set cell size
r <- raster(nrows=25, ncols=20, ext=jc.extent)
####################################################################################
#rook
####################################################################################
#Join Count Analysis for NO LOCKDOWN
nolockdown.rast <- rasterize(nolockdown.spdf, r, field = 1)
nolockdown.rast[is.na(nolockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(nolockdown.rast), ncol = ncol(nolockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(nolockdown.rast@data@values), lwbnl, alternative = "greater")
#Join Count Analysis for LOCKDOWN
lockdown.rast <- rasterize(lockdown.spdf, r, field = 1)
lockdown.rast[is.na(lockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(lockdown.rast), ncol = ncol(lockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(lockdown.rast@data@values), lwbnl, alternative = "greater")
#Join Count Analysis for NO LOCKDOWN
nolockdown.rast <- rasterize(nolockdown.spdf, r1, field = 1)
r1 <- raster(nrows=50, ncols=50, ext=jc.extent)
#Join Count Analysis for NO LOCKDOWN
nolockdown.rast <- rasterize(nolockdown.spdf, r1, field = 1)
nbnl <- cell2nb(nrow = nrow(nolockdown.rast), ncol = ncol(nolockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(nolockdown.rast@data@values), lwbnl, alternative = "greater")
r1 <- raster(nrows=50, ncols=50, ext=jc.extent)
#Join Count Analysis for NO LOCKDOWN
nolockdown.rast <- rasterize(nolockdown.spdf, r1, field = 1)
nolockdown.rast[is.na(nolockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(nolockdown.rast), ncol = ncol(nolockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(nolockdown.rast@data@values), lwbnl, alternative = "greater")
#Join Count Analysis for LOCKDOWN
lockdown.rast <- rasterize(lockdown.spdf, r1, field = 1)
lockdown.rast[is.na(lockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(lockdown.rast), ncol = ncol(lockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(lockdown.rast@data@values), lwbnl, alternative = "greater")
#Join Count Analysis for NO LOCKDOWN
nolockdown.rast <- rasterize(nolockdown.spdf, r1, field = 1)
nolockdown.rast[is.na(nolockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(nolockdown.rast), ncol = ncol(nolockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(nolockdown.rast@data@values), lwbnl, alternative = "greater")
#Join Count Analysis for LOCKDOWN
lockdown.rast <- rasterize(lockdown.spdf, r1, field = 1)
lockdown.rast[is.na(lockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(lockdown.rast), ncol = ncol(lockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(lockdown.rast@data@values), lwbnl, alternative = "greater")
load(file= "nolockdown.spdf", verbose = FALSE)
nolockdown.spdf <- nolockdown
coordinates(nolockdown.spdf) <- c("longitude", "latitude")
load(file= "lockdown.spdf", verbose = FALSE)
lockdown.spdf <- lockdown
coordinates(lockdown.spdf) <- c("longitude", "latitude")
#Define the extent for the join count analyses for lockdown
jc.extent <- extent(39,46,30,40)
#Set cell size
r <- raster(nrows=25, ncols=20, ext=jc.extent)
####################################################################################
#rook
####################################################################################
#Join Count Analysis for NO LOCKDOWN
nolockdown.rast <- rasterize(nolockdown.spdf, r, field = 1)
nolockdown.rast[is.na(nolockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(nolockdown.rast), ncol = ncol(nolockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(nolockdown.rast@data@values), lwbnl, alternative = "greater")
#Join Count Analysis for LOCKDOWN
lockdown.rast <- rasterize(lockdown.spdf, r, field = 1)
lockdown.rast[is.na(lockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(lockdown.rast), ncol = ncol(lockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(lockdown.rast@data@values), lwbnl, alternative = "greater")
r1 <- raster(nrows=50, ncols=50, ext=jc.extent)
#Join Count Analysis for NO LOCKDOWN
nolockdown.rast <- rasterize(nolockdown.spdf, r1, field = 1)
nolockdown.rast[is.na(nolockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(nolockdown.rast), ncol = ncol(nolockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(nolockdown.rast@data@values), lwbnl, alternative = "greater")
#Join Count Analysis for LOCKDOWN
lockdown.rast <- rasterize(lockdown.spdf, r1, field = 1)
lockdown.rast[is.na(lockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(lockdown.rast), ncol = ncol(lockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(lockdown.rast@data@values), lwbnl, alternative = "greater")
r1 <- raster(nrows=30, ncols=30, ext=jc.extent)
#Join Count Analysis for NO LOCKDOWN
nolockdown.rast <- rasterize(nolockdown.spdf, r1, field = 1)
nolockdown.rast[is.na(nolockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(nolockdown.rast), ncol = ncol(nolockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(nolockdown.rast@data@values), lwbnl, alternative = "greater")
#Join Count Analysis for LOCKDOWN
lockdown.rast <- rasterize(lockdown.spdf, r1, field = 1)
lockdown.rast[is.na(lockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(lockdown.rast), ncol = ncol(lockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(lockdown.rast@data@values), lwbnl, alternative = "greater")
r1 <- raster(nrows=10, ncols=10, ext=jc.extent)
#Join Count Analysis for NO LOCKDOWN
nolockdown.rast <- rasterize(nolockdown.spdf, r1, field = 1)
nolockdown.rast[is.na(nolockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(nolockdown.rast), ncol = ncol(nolockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(nolockdown.rast@data@values), lwbnl, alternative = "greater")
#Join Count Analysis for LOCKDOWN
lockdown.rast <- rasterize(lockdown.spdf, r1, field = 1)
lockdown.rast[is.na(lockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(lockdown.rast), ncol = ncol(lockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(lockdown.rast@data@values), lwbnl, alternative = "greater")
r1 <- raster(nrows=30, ncols=30, ext=jc.extent)
#Join Count Analysis for NO LOCKDOWN
nolockdown.rast <- rasterize(nolockdown.spdf, r1, field = 1)
nolockdown.rast[is.na(nolockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(nolockdown.rast), ncol = ncol(nolockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(nolockdown.rast@data@values), lwbnl, alternative = "greater")
#Join Count Analysis for LOCKDOWN
lockdown.rast <- rasterize(lockdown.spdf, r1, field = 1)
lockdown.rast[is.na(lockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(lockdown.rast), ncol = ncol(lockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(lockdown.rast@data@values), lwbnl, alternative = "greater")
r1 <- raster(nrows=12.5, ncols=12.5, ext=jc.extent)
#Join Count Analysis for NO LOCKDOWN
nolockdown.rast <- rasterize(nolockdown.spdf, r1, field = 1)
nolockdown.rast[is.na(nolockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(nolockdown.rast), ncol = ncol(nolockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(nolockdown.rast@data@values), lwbnl, alternative = "greater")
#Join Count Analysis for LOCKDOWN
lockdown.rast <- rasterize(lockdown.spdf, r1, field = 1)
lockdown.rast[is.na(lockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(lockdown.rast), ncol = ncol(lockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(lockdown.rast@data@values), lwbnl, alternative = "greater")
load(file= "nolockdown.spdf", verbose = FALSE)
nolockdown.spdf <- nolockdown
coordinates(nolockdown.spdf) <- c("longitude", "latitude")
load(file= "lockdown.spdf", verbose = FALSE)
lockdown.spdf <- lockdown
coordinates(lockdown.spdf) <- c("longitude", "latitude")
#Define the extent for the join count analyses for lockdown
jc.extent <- extent(39,46,30,40)
#Set cell size
r <- raster(nrows=25, ncols=20, ext=jc.extent)
####################################################################################
#rook
####################################################################################
#Join Count Analysis for NO LOCKDOWN
nolockdown.rast <- rasterize(nolockdown.spdf, r, field = 1)
nolockdown.rast[is.na(nolockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(nolockdown.rast), ncol = ncol(nolockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(nolockdown.rast@data@values), lwbnl, alternative = "greater")
#Join Count Analysis for LOCKDOWN
lockdown.rast <- rasterize(lockdown.spdf, r, field = 1)
lockdown.rast[is.na(lockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(lockdown.rast), ncol = ncol(lockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(lockdown.rast@data@values), lwbnl, alternative = "greater")
nbnl.queen <- cell2nb(nrow = nrow(nolockdown.rast), ncol = ncol(nolockdown.rast), type = "queen")
lwbnl.queen <- nb2listw(nbnl.queen, style = "B")
joincount.test(as.factor(nolockdown.rast@data@values), lwbnl.queen, alternative = "greater")
nbl.queen <- cell2nb(nrow = nrow(lockdown.rast), ncol = ncol(lockdown.rast), type = "queen")
lwbl.queen <- nb2listw(nbl.queen, style = "B")
joincount.test(as.factor(lockdown.rast@data@values), lwbl.queen, alternative = "greater")
r1 <- raster(nrows=12.5, ncols=12.5, ext=jc.extent)
#Join Count Analysis for NO LOCKDOWN
nolockdown.rast <- rasterize(nolockdown.spdf, r1, field = 1)
nolockdown.rast[is.na(nolockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(nolockdown.rast), ncol = ncol(nolockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(nolockdown.rast@data@values), lwbnl, alternative = "greater")
#Join Count Analysis for LOCKDOWN
lockdown.rast <- rasterize(lockdown.spdf, r1, field = 1)
lockdown.rast[is.na(lockdown.rast)] <- 0
nbnl <- cell2nb(nrow = nrow(lockdown.rast), ncol = ncol(lockdown.rast))
# Convert the neighbors list to a 'weights' list;
lwbnl <- nb2listw(nbnl, style = "B")
joincount.test(as.factor(lockdown.rast@data@values), lwbnl, alternative = "greater")
#########################################################################################
rm(list=ls()) #Clearing workspace
#Data
COVID19=as.data.frame(read.dta13("COVID19PeaceDataset_DAY_ALL.dta"))
#packages
library("tidyverse")
library("dplyr")
library("spdep")
library("raster")
library("pgirmess")
library("readxl")
library(readstata13)
#Data
COVID19=as.data.frame(read.dta13("COVID19PeaceDataset_DAY_ALL.dta"))
setwd("~/Dropbox/COVID19peace/Replication Files_(New)/ReplicationFiles_(OLD)")
#Data
COVID19=as.data.frame(read.dta13("COVID19PeaceDataset_DAY_ALL.dta"))
#subset by Iraq & including only variables to be used
iraq_conflict= COVID19[COVID19$country=="Iraq", ] #Iraq data
load("/Users/hannahbirnir/Dropbox/COVID19peace/APSR/APSR Dataverse Oct2020/LDV GIS Main/GIS.RData")
View(GIS)
View(iraq_conflict)
#No lockdown weeks
nolockdown=iraq_conflict%>%
filter(week>10 & week<27) %>%
dplyr::select("isisandlikely", "latitude","longitude" )
nolockdown1=GIS%>%
filter(week>10 & week<27) %>%
dplyr::select("isisandlikely", "latitude","longitude" )
View(GIS)
View(COVID19)
View(iraq_conflict)
View(nolockdown)
#No lockdown weeks
nolockdown=iraq_conflict%>%
filter(week>10 & week<27) %>%
dplyr::select("isisandlikely", "latitude","longitude" )%>%
filter("isisandlikely"==1)
#No lockdown weeks
nolockdown=iraq_conflict%>%
filter(week>10 & week<27) %>%
dplyr::select("isisandlikely", "latitude","longitude" )%>%
filter(isisandlikely=1)
#No lockdown weeks
nolockdown=iraq_conflict%>%
filter(week>10 & week<27) %>%
dplyr::select("isisandlikely", "latitude","longitude" )%>%
filter(isisandlikely=1)
#No lockdown weeks
nolockdown=iraq_conflict%>%
filter(week>10 & week<27) %>%
dplyr::select("isisandlikely", "latitude","longitude" )%>%
filter("isisandlikely"=1)
#No lockdown weeks
nolockdown=iraq_conflict%>%
filter(week>10 & week<27) %>%
dplyr::select("isisandlikely", "latitude","longitude" )
View(nolockdown)
#No lockdown weeks
nolockdown=iraq_conflict%>%
filter(week>10 & week<27) %>%
dplyr::select("isisandlikely", "latitude","longitude" )%>%
filter(isisandlikely=1)
#No lockdown weeks
nolockdown=iraq_conflict%>%
filter(week>10 & week<27) %>%
dplyr::select("isisandlikely", "latitude","longitude" )%>%
dplyr::filter(isisandlikely=1)
#No lockdown weeks
nolockdown=iraq_conflict%>%
filter(week>10 & week<27) %>%
dplyr::select("isisandlikely", "latitude","longitude" )%>%
dplyr::filter(isisandlikely==1)
#Creating Cells of Presence/Absence (For Join Count Analysis)
# Convert nolockdown SpatialPointsDataFrame
nolockdown.spdf <- nolockdown
coordinates(nolockdown.spdf) <- c("longitude", "latitude")
save(nolockdown, file = "nolockdown.spdf")
plot(nolockdown.spdf, axes=TRUE) #to see the axes for defining area
#same for lockdown
lockdown.spdf <- lockdown
coordinates(lockdown.spdf) <- c("longitude", "latitude")
save(lockdown, file = "lockdown.spdf")
#Define the extent for the join count analyses for lockdown
jc.extent <- extent(39,46,30,40)
#set up a blank raster ASK JIM I THINK THIS IS WERE SELECTION OF GRID COMPARISON HAPPENS
#According to JIM this is where the cell size is set
#Run sev eral - ythis is determining the cell sice so scale of observation
r <- raster(nrows=25, ncols=20, ext=jc.extent)
nolockdown.rast <- rasterize(nolockdown.spdf, r, field = 1)
nolockdown.rast[is.na(nolockdown.rast)] <- 0
# plot the result
plot(nolockdown.rast)
plot(nolockdown.spdf, add = TRUE)
#same for no lockdown
lockdown.rast <- rasterize(lockdown.spdf, r, field = 1)
lockdown.rast[is.na(lockdown.rast)] <- 0
library("spdep")
library("raster")
library("pgirmess")
library("readxl")
# plot the result
plot(nolockdown.rast)
plot(nolockdown.spdf, add = TRUE)
#Setting Up and Running Join Count Analysis for NO LOCKDOWN
# Generate neighbors list - the function is 'cell2nb' and the arguments are
# the number of rows and colums in your grid; get those
# characteristics from your rasters using 'nrow' and 'ncol'
# commands, nested in the cell2nb function (as ilustrated below). Note, the
# default for this is 'rook',
nbnl <- cell2nb(nrow = nrow(nolockdown.rast), ncol = ncol(nolockdown.rast))
# Convert the neighbors list to a 'weights' list;
#The nb2listw function supplements a neighbours list with spatial weights for the chosen coding scheme.
# using 'style='B' (as a Binary weights matrix).
lwbnl <- nb2listw(nbnl, style = "B")
# First, the regular join count test (Testing the hypothesis
# of aggregation among like categories; add the argument 'alternative='less'
# to reverse this)
#lwbnl are the weights
jcnl=joincount.test(as.factor(nolockdown.rast@data@values), lwbnl, alternative = "greater")
jcnl
load(file= "no.curf.map.Rdata", verbose = FALSE)
setwd("~/Dropbox/COVID19peace/APSR/APSR Dataverse Oct2020/LDV GIS Main")
load(file= "ne_iraq_gov.shp", verbose = FALSE)
load(file= "no.curf.map.Rdata", verbose = FALSE)
ggplot(no.curf.map, aes(x=longitude , y=latitude)) +
geom_point(size=1, color="#6F7378")+
geom_sf(data = ne_iraq_gov, fill=NA, show.legend=FALSE, lwd=.5) + #layers province outline
stat_density_2d(alpha=2, contour = TRUE, color="#4C4E52") +
annotate(geom="text", x=44.4, y=33.1, label="Baghdad",
color="black", angle=15, size=4, fontface="bold",family="Times New Roman")+ #adds text on xy coordinates
annotate(geom="text", x=43, y=36.6, label="Mosul",
color="black", angle=25,size=4, fontface="bold",family="Times New Roman")+ #adds text on xy coordinates
annotate(geom="text", x=44.37, y=35.46, label="Kirkuk",
color="black", angle=15,size=4, fontface="bold",family="Times New Roman")+ #adds text on xy coordinates
annotate(geom="text", x=44.60, y=33.75, label="Baqubah",
color="black", angle=15, size=5, fontface="bold",family="Times New Roman")+ #adds text on xy coordinates
coord_sf(xlim = c(39, 47), ylim = c(30.5, 37), expand = FALSE)+ #zooms in on the map
theme(legend.position='none')+
theme_bw()+
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks.y=element_blank(),
axis.ticks.x=element_blank()) #eliminates various axis ticks and legends
ggplot(no.curf.map, aes(x=longitude , y=latitude)) +
geom_point(size=1, color="red")+
geom_sf(data = ne_iraq_gov, fill=NA, show.legend=FALSE, lwd=.5) + #layers province outline
stat_density_2d(alpha=2, contour = TRUE, color="orange") +
annotate(geom="text", x=44.4, y=33.1, label="Baghdad",
color="black", angle=15, size=4, fontface="bold",family="Times New Roman")+ #adds text on xy coordinates
annotate(geom="text", x=43, y=36.6, label="Mosul",
color="black", angle=25,size=4, fontface="bold",family="Times New Roman")+ #adds text on xy coordinates
annotate(geom="text", x=44.37, y=35.46, label="Kirkuk",
color="black", angle=15,size=4, fontface="bold",family="Times New Roman")+ #adds text on xy coordinates
annotate(geom="text", x=44.60, y=33.75, label="Baqubah",
color="black", angle=15, size=5, fontface="bold",family="Times New Roman")+ #adds text on xy coordinates
coord_sf(xlim = c(39, 47), ylim = c(30.5, 37), expand = FALSE)+ #zooms in on the map
theme(legend.position='none')+
theme_bw()+
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks.y=element_blank(),
axis.ticks.x=element_blank()) #eliminates various axis ticks and legends
#Curfew Chisquare plot
load(file= "curf.chi.plot.Rdata", verbose = FALSE)
ggplot(data=curf.chi.plot, aes(x=Location, y=Events, fill=time)) +
geom_bar(stat="identity", position=position_dodge())+
theme_bw()+
scale_fill_manual(values=c("red", "orange"))+
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks.y=element_blank(),
axis.ticks.x=element_blank(),
axis.text.x = element_text(family="Times New Roman", size = 11),
axis.text.y = element_text(family="Times New Roman", size = 11),
axis.title.x = element_text(family="Times New Roman", size = 12),
axis.title.y = element_text(family="Times New Roman", size = 12))+
annotate(geom="text", x=1, y=117, label="Chi-square",
color="black", angle=0, size=4, fontface="bold",family="Times New Roman")+ #adds text on xy coordinates
annotate(geom="text", x=1, y=110, label="p = 0.01246",
color="black", angle=0, size=4, fontface="bold",family="Times New Roman") #adds text on xy coordinates
ggplot(data=curf.chi.plot, aes(x=Location, y=Events, fill=time)) +
geom_bar(stat="identity", position=position_dodge())+
theme_bw()+
scale_fill_manual(values=c("orange", "red"))+
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks.y=element_blank(),
axis.ticks.x=element_blank(),
axis.text.x = element_text(family="Times New Roman", size = 11),
axis.text.y = element_text(family="Times New Roman", size = 11),
axis.title.x = element_text(family="Times New Roman", size = 12),
axis.title.y = element_text(family="Times New Roman", size = 12))+
annotate(geom="text", x=1, y=117, label="Chi-square",
color="black", angle=0, size=4, fontface="bold",family="Times New Roman")+ #adds text on xy coordinates
annotate(geom="text", x=1, y=110, label="p = 0.01246",
color="black", angle=0, size=4, fontface="bold",family="Times New Roman") #adds text on xy coordinates
load(file= "curf.map.Rdata", verbose = FALSE)
ggplot(curf.map, aes(x=longitude , y=latitude)) +
geom_point(size=1, color="red")+
geom_sf(data = ne_iraq_gov, fill=NA, show.legend=FALSE, lwd=.5) + #layers province outline
stat_density_2d(alpha=2, contour = TRUE, color="orange") +
annotate(geom="text", x=44.4, y=33.1, label="Baghdad",
color="black", angle=15, size=4, fontface="bold",family="Times New Roman")+ #adds text on xy coordinates
annotate(geom="text", x=43, y=36.6, label="Mosul",
color="black", angle=25,size=4, fontface="bold",family="Times New Roman")+ #adds text on xy coordinates
annotate(geom="text", x=44.37, y=35.46, label="Kirkuk",
color="black", angle=15,size=4, fontface="bold",family="Times New Roman")+ #adds text on xy coordinates
annotate(geom="text", x=44.60, y=33.75, label="Baqubah",
color="black", angle=15, size=4, fontface="bold",family="Times New Roman")+ #adds text on xy coordinates
coord_sf(xlim = c(39, 47), ylim = c(30.5, 37), expand = FALSE)+ #zooms in on the map
theme(legend.position='none')+
theme_bw()+
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks.y=element_blank(),
axis.ticks.x=element_blank()) #eliminates various axis ticks and legends
load(file= "no.tban.map.Rdata", verbose = FALSE)
#Before travel ban
ggplot() +
geom_sf(data = ne_iraq_gov,show.legend=FALSE)+ #layers country outline
geom_sf(data =no.tban.map, aes(fill=N.Events)) +
scale_fill_gradient( low = "#ace5ee",
high = "red", limits=c(0,100))+  #change to respond to R&R 12.14.2020
coord_sf(xlim = c(38.8, 48.5), ylim = c(29, 37.5), expand = FALSE)+ #zooms in on the map
theme_bw()+ #eliminates fills
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.title.x=element_blank(),
axis.title.y=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank())+ #eliminates various axis ticks and legends
theme(legend.title = element_text(size=12))+ #specifies legend text size
theme(legend.position="left") # positions the legend with respect to the map
load(file= "tban.map.Rdata", verbose = FALSE)
ggplot() +
geom_sf(data = ne_iraq_gov,show.legend=FALSE)+ #layers country outline
geom_sf(data =tban.map, aes(fill=N.Events)) +
scale_fill_gradient( low = "#ace5ee",
high = "red", limits=c(0,100))+
coord_sf(xlim = c(38.8, 48.5), ylim = c(29, 37.5), expand = FALSE)+ #zooms in on the map
theme_bw()+ #eliminates fills
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.title.x=element_blank(),
axis.title.y=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank())+ #eliminates various axis ticks and legends
theme(legend.title = element_text(size=12))+ #specifies legend text size
theme(legend.position="left") # positions the legend with respect to the map
